export const host = "https://apis.netstart.cn/coffee";
export const appkey = 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='; // 替换为实际的 appkey


// 封装GET请求
export const get = (url, data = {}) => {
  return new Promise((resolve, reject) => {
    uni.request({
	  header: { 'Content-Type': 'application/json' },
      url: host + url,
      data: { ...data, appkey }, // 自动添加 appkey
	  method: 'GET',
      success(res) {
        resolve(res.data);
      },
      fail(err) {
        reject("请求失败");
      }
    });
  });
};

// 封装POST请求
export const post = (url, data = {}) => {
  return new Promise((resolve, reject) => {
    uni.request({
	  header: { 'Content-Type': 'application/x-www-form-urlencoded' },
      url: host + url,
	  data: { ...data, appkey }, // 自动添加 appkey
      method: 'POST',
      success(res) {
        resolve(res.data);
      },
      fail(err) {
        reject("请求失败");
      }
    });
  });
}








